package cn.hxth.cloud.provider.updater;

import cn.hxth.cloud.api.common.util.DateProvider;
import cn.hxth.cloud.api.domain.OrderInfoItem;
import cn.hxth.cloud.api.domain.Product;
import cn.hxth.cloud.api.mapper.ProductMapper;

import java.util.List;
import java.util.Map;

public class OrderProductUpdater extends AbstractProductUpdater {
    private Map<Long,OrderInfoItem> map ;

    public OrderProductUpdater(List<Product> products, ProductMapper productMapper, DateProvider dateProvider, Map<Long, OrderInfoItem> map) {
        super(products, productMapper, dateProvider);
        this.map = map;
    }


    @Override
    protected void updateLockedInventory() {
        for(Product product:products){
            OrderInfoItem item = map.get(product.getId());
            product.setLockedInventory(product.getLockedInventory()+item.getCount());
        }
    }

    @Override
    protected void updateInventory() {
    }

}
